package com.baizhi.yyl.controller;


import com.baizhi.yyl.dto.PageDTO;
import com.baizhi.yyl.service.CategoryService;
import com.baizhi.yyl.vo.CommonQueryPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @PostMapping("/category/queryOnePage")
    public CommonQueryPageVO queryOnePage(@RequestBody PageDTO pageDTO){
        return categoryService.queryOnePage(pageDTO);
    }
/*
    @PostMapping("/category/add")
    public CommonVO add(@RequestBody Category category){
        return categoryService.add(category);
    }

    @PostMapping("/category/delete")
    public CommonVO delete(@RequestBody Category category){
        try {
            String message = categoryService.deletes(category);
            return CommonVO.success(message);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonVO.faild(e.getMessage());
        }
    }

    @PostMapping("/category/deletes")
    public CommonVO deletes(@RequestBody Category category){
        return categoryService.delete(category);
    }

    @GetMapping("/category/queryById")
    public Category queryById(String id){
        return categoryService.queryById(id);
    }

    @PostMapping("/category/update")
    public CommonVO update(@RequestBody Category category){
        return categoryService.update(category);
    }

    @PostMapping("/category/queryTwoPage")
    public CommonQueryPageVO queryTwoPage(@RequestBody CategoryPageDTO categoryPageDTO){
        return categoryService.queryTwoPage(categoryPageDTO);
    }


    // 按照级别查询所有类别
    @PostMapping("/category/queryByLevelsCategory")
    public List<Category> queryByLevelsCategory(Integer levels){
        return categoryService.queryByLevelsCategory(levels);
    }*/

}
